package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.Comment;
import com.cskaoyan.bean.bo.CommentBo;
import com.cskaoyan.bean.vo.CommentList1Vo;
import com.cskaoyan.service.wxService.WxCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("wx/comment")
public class WxCommentController {

    @Autowired
    WxCommentService wxCommentService;

    @RequestMapping("list")
    public BaseRespVo getWxCommentList(Integer valueId,Byte type,Integer size, Integer page,Integer showType){
        CommentList1Vo list = wxCommentService.getCommentList(valueId, type, size, page, showType);
        return BaseRespVo.ok(list);
    }

    @RequestMapping("count")
    public BaseRespVo getCommentCount(Integer valueId , Byte type){
        Map<String,Object> count = wxCommentService.getCommentCount(valueId,type);
        return BaseRespVo.ok(count);
    }

    @RequestMapping("post")
    public BaseRespVo postComment(@RequestBody CommentBo commentBo){
        Integer valueId =commentBo.getOrderGoodsId();

        String content = commentBo.getContent();
        Byte type = commentBo.getType();
        Short star = commentBo.getStar();
        Boolean hasPicture = commentBo.getHasPicture();
        String[] picUrls = commentBo.getPicUrls();
        Comment comment = wxCommentService.postComment(type, valueId, content, star, hasPicture, picUrls);
        return  BaseRespVo.ok(comment);
    }

}
